//
// Copyright 2019 LINE Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

package com.linecorp.android.featureflag.model

/**
 * A data class represents a build variant, that is, a pair of build type and flavors.
 *
 * This class must be public because an extension proxy class generated by Gradle requires this
 * class.
 */
data class BuildVariant(
    val buildType: Element.BuildType,
    val flavors: Set<Element.Flavor>
) {
    internal fun includes(variant: Element): Boolean = when (variant) {
        is Element.BuildType -> variant == buildType
        is Element.Flavor -> flavors.contains(variant)
    }

    sealed class Element {
        data class BuildType(val buildTypeName: String) : Element()
        data class Flavor(val productFlavorName: String) : Element()
    }
}
